<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<!-- Mirrored from www.wolfssl.com/wolfSSL/Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Jan 2017 13:35:09 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8" /><!-- /Added by HTTrack -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="Generator" content="iWeb 3.0.4"/>
<meta name="iWeb-Build" content="local-build-20170103"/>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<meta name="viewport" content="width=770"/>
<title>wolfSSL - Docs | wolfSSL Manual - Chapter 17.8 (API Reference, Connection, Session, I/O)</title>
<link rel="stylesheet" type="text/css" media="screen,print" href="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io.css"/>
<!--[if lt IE 8]><link rel='stylesheet' type='text/css' media='screen,print' href='Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-ioIE.css'/><![endif]-->
<!--[if gte IE 8]><link rel='stylesheet' type='text/css' media='screen,print' href='Media/IE8.css'/><![endif]-->
<script type="text/javascript" src="Scripts/iWebSite.js"></script>
<script type="text/javascript" src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io.js"></script>
<meta name="description" content="wolfSSL API reference functions related to the SSL/TLS connection, session management, and input/output."/><meta name="keywords" content="embedded ssl, ssl library, lightweight ssl, open source ssl, open source web server, tls 1.2, embedded security, small openssl, smart grid, connected home, ecc, suite b, fips, encryption security software, ssl inspection"/><meta name="robots" content="follow,index"/> <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','../../www.google-analytics.com/analytics.js','ga');ga('create','UA-64826966-1','auto');ga('send','pageview');</script>
 
<script>//<![CDATA[
window.zEmbed||function(e,t){var n,o,d,i,s,a=[],r=document.createElement("iframe");window.zEmbed=function(){a.push(arguments)},window.zE=window.zE||window.zEmbed,r.src="javascript:false",r.title="",r.role="presentation",(r.frameElement||r).style.cssText="display: none",d=document.getElementsByTagName("script"),d=d[d.length-1],d.parentNode.insertBefore(r,d),i=r.contentWindow,s=i.document;try{o=s}catch(c){n=document.domain,r.src='javascript:var d=document.open();d.domain="'+n+'";void(0);',o=s}o.open()._l=function(){var o=this.createElement("script");n&&(this.domain=n),o.id="js-iframe-async",o.src=e,this.t=+new Date,this.zendeskHost=t,this.zEQueue=a,this.body.appendChild(o)},o.write('<body onload="document._l();">'),o.close()}("../../assets.zendesk.com/embeddable_framework/main.js","wolfssl.zendesk.com");
//]]></script>
  </head>
<body style="background: rgb(255, 255, 255); margin: 0pt; " onload="onPageLoad();">
<div style="text-align: center; ">
<div style="margin-bottom: 20px; margin-left: auto; margin-right: auto; margin-top: 20px; overflow: hidden; position: relative; word-wrap: break-word;  background: rgb(255, 255, 255); text-align: left; width: 770px; " id="body_content">
<div style="float: left; margin-left: 0px; position: relative; width: 770px; z-index: 0; " id="nav_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
<div style="clear: both; height: 0px; line-height: 0px; " class="spacer"> </div>
</div>
<div style="float: left; height: 0px; line-height: 0px; margin-left: 0px; position: relative; width: 770px; z-index: 10; " id="header_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
</div>
<div style="margin-left: 0px; position: relative; width: 770px; z-index: 5; " id="body_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
<div id="id1" style="height: 38px; left: 375px; position: absolute; top: 157px; width: 361px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_361_38" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style">wolfSSL Manual</p>
</div>
</div>
</div>
<div id="id2" style="height: 24px; left: 193px; position: absolute; top: 122px; width: 268px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_268_24" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_1"><a class="class1" title="Docs.html" href="Docs.html">Docs</a> <span class="style">-&gt;</span> <span class="style_1">wolfSSL Manual</span></p>
</div>
</div>
</div>
<div style="height: 1px; width: 698px;  height: 1px; left: 37px; position: absolute; top: 220px; width: 698px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 698px; ">
<img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_1.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 698px; "/>
</div>
</div>
<div style="height: 37px; width: 545px;  height: 37px; left: 191px; position: absolute; top: 80px; width: 545px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 545px; ">
<img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_2.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 545px; "/>
</div>
</div>
<div id="id3" style="height: 25px; left: 200px; position: absolute; top: 84px; width: 43px; z-index: 1; " class="style_SkipStroke_1 shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_43_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_2"><a class="class2" title="Home.html" href="Home.html">Home</a></p>
</div>
</div>
</div>
<div id="id4" style="height: 25px; left: 365px; position: absolute; top: 84px; width: 72px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_72_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class3" title="https://wolfssl.com/wolfSSL/download/downloadForm.php" href="https://wolfssl.com/wolfSSL/download/downloadForm.php">Download</a></p>
</div>
</div>
</div>
<div id="id5" style="height: 25px; left: 439px; position: absolute; top: 84px; width: 59px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_59_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class4" title="License.html" href="License.html">License</a></p>
</div>
</div>
</div>
<div id="id6" style="height: 25px; left: 499px; position: absolute; top: 84px; width: 44px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_44_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class5" title="Blog/Blog.html" href="Blog/Blog.html">Blog</a></p>
</div>
</div>
</div>
<div id="id7" style="height: 25px; left: 589px; position: absolute; top: 84px; width: 80px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_80_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class6" title="Community.html" href="Community.html">Community</a></p>
</div>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 245px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_3.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 296px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_4.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 363px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_5.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 438px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_6.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 498px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_7.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 589px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_8.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div id="id8" style="height: 25px; left: 671px; position: absolute; top: 84px; width: 61px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_61_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class7" title="Contact.html" href="Contact.html">Contact</a></p>
</div>
</div>
</div>
<div id="id9" style="height: 25px; left: 249px; position: absolute; top: 84px; width: 44px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_44_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_2"><a class="class8" title="About.html" href="About.html">About</a></p>
</div>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 670px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_9.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div id="id10" style="height: 25px; left: 298px; position: absolute; top: 84px; width: 63px; z-index: 1; " class="style_SkipStroke_1 shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_63_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class9" title="Products.html" href="Products.html">Products</a></p>
</div>
</div>
</div>
<div id="id11" style="height: 25px; left: 549px; position: absolute; top: 84px; width: 41px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_41_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_2"><a class="class10" title="Docs.html" href="Docs.html">Docs</a></p>
</div>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 545px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_10.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div id="id12" style="height: 27px; left: 634px; position: absolute; top: 224px; width: 102px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_102_27" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_4"><a class="class11" title="Docs-wolfssl-manual-17-9-wolfssl-api-dtls.html" href="Docs-wolfssl-manual-17-9-wolfssl-api-dtls.html">Next Chapter</a></p>
</div>
</div>
</div>
<div id="id13" style="height: 25px; left: 35px; position: absolute; top: 224px; width: 125px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_125_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_5"><a class="class12" title="Docs-wolfssl-manual-17-7-wolfssl-api-informational.html" href="Docs-wolfssl-manual-17-7-wolfssl-api-informational.html">Previous Chapter</a></p>
</div>
</div>
</div>
<div id="id14" style="height: 27px; left: 59px; position: absolute; top: 190px; width: 196px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_196_27" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_6"><a class="class13" title="https://www.wolfssl.com/documentation/wolfSSL-Manual.pdf" href="https://www.wolfssl.com/documentation/wolfSSL-Manual.pdf">Download wolfSSL Manual (PDF)</a></p>
</div>
</div>
</div>
<div style="height: 22px; width: 22px;  height: 22px; left: 33px; position: absolute; top: 191px; width: 22px; z-index: 1; " class="tinyText style_SkipStroke_2">
<img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/PDF.png" alt="" style="border: none; height: 22px; width: 22px; "/>
</div>
<div id="id15" style="height: 25px; left: 323px; position: absolute; top: 224px; width: 125px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_125_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_7"><a title="Docs-wolfssl-manual-toc.html" href="Docs-wolfssl-manual-toc.html">Table of Contents</a></p>
</div>
</div>
</div>
<div id="id16" style="height: 10878px; left: 35px; position: absolute; top: 281px; width: 701px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_701_10878" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-top: 0pt; " class="paragraph_style_8">Chapter 17: wolfSSL API Reference<br/></p>
<p class="paragraph_style_8"><br/></p>
<p class="paragraph_style_9">17.8  Connection, Session, and I/O<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_10">The functions in this section deal with setting up the SSL/TLS connection, managing SSL sessions, and input/output.<span class="style_2"><br/></span></p>
<p class="paragraph_style_11"><br/></p>
<p class="paragraph_style_11"><br/></p>
<div class="paragraph paragraph_style_11"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_11.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_11"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">CyaSSL_accept<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int  CyaSSL_accept(CYASSL* ssl);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">This function is called on the server side and waits for an SSL client to initiate the SSL/TLS handshake.  When this function is called, the underlying communication channel has already been set up.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">CyaSSL_accept() works with both blocking and non-blocking I/O.  When the underlying I/O is non-blocking, CyaSSL_accept() will return when the underlying I/O could not satisfy the needs of of CyaSSL_accept to continue the handshake.  In this case, a call to CyaSSL_get_error() will yield either <span class="style_3">SSL_ERROR_WANT_READ</span> or <span class="style_3">SSL_ERROR_WANT_WRITE</span>.  The calling process must then repeat the call to CyaSSL_accept when data is available to read and CyaSSL will pick up where it left off. When using a non-blocking socket, nothing needs to be done, but select() can be used to check for the required condition.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">If the underlying I/O is blocking, CyaSSL_accept() will only return once the handshake has been finished or an error occurred.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10">If successful the call will return <span class="style_3">SSL_SUCCESS</span>.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">SSL_FATAL_ERROR</span> will be returned if an error occurred.  To get a more detailed error code, call CyaSSL_get_error().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - a pointer to a CYASSL structure, created using CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">int ret = 0;<br/></p>
<p class="paragraph_style_14">int err = 0;<br/></p>
<p class="paragraph_style_14">CYASSL* ssl;<br/></p>
<p class="paragraph_style_14">char buffer[80];<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = CyaSSL_accept(ssl);<br/></p>
<p class="paragraph_style_14">if (ret != SSL_SUCCESS) {<br/></p>
<p class="paragraph_style_14">err = CyaSSL_get_error(ssl, ret);<br/></p>
<p class="paragraph_style_14">printf(“error = %d, %s\n”, err, CyaSSL_ERR_error_string(err, buffer));<br/>}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_get_error<br/></p>
<p class="paragraph_style_10">CyaSSL_connect<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_12.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_12">CyaSSL_connect<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int  CyaSSL_connect(CYASSL* ssl);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">This function is called on the client side and initiates an SSL/TLS handshake with a server.  When this function is called, the underlying communication channel has already been set up.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">CyaSSL_connect() works with both blocking and non-blocking I/O.  When the underlying I/O is non-blocking, CyaSSL_connect() will return when the underlying I/O could not satisfy the needs of of CyaSSL_connect to continue the handshake.  In this case, a call to CyaSSL_get_error() will yield either <span class="style_3">SSL_ERROR_WANT_READ</span> or <span class="style_3">SSL_ERROR_WANT_WRITE</span>.  The calling process must then repeat the call to CyaSSL_connect() when the underlying I/O is ready and CyaSSL will pick up where it left off. When using a non-blocking socket, nothing needs to be done, but select() can be used to check for the required condition.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">If the underlying I/O is blocking, CyaSSL_connect() will only return once the handshake has been finished or an error occurred.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">CyaSSL takes a different approach to certificate verification than OpenSSL does.  The default policy for the client is to verify the server, this means that if you don't load CAs to verify the server you'll get a connect error, unable to verify (-155).  It you want to mimic OpenSSL behavior of having SSL_connect succeed even if verifying the server fails and reducing security you can do this by calling:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">before calling SSL_new();  Though it's not recommended.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10">If successful the call will return <span class="style_3">SSL_SUCCESS</span>.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">SSL_FATAL_ERROR</span> will be returned if an error occurred.  To get a more detailed error code, call CyaSSL_get_error().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - a pointer to a CYASSL structure, created using CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">int ret = 0;<br/></p>
<p class="paragraph_style_14">int err = 0;<br/></p>
<p class="paragraph_style_14">CYASSL* ssl;<br/></p>
<p class="paragraph_style_14">char buffer[80];<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = CyaSSL_connect(ssl);<br/></p>
<p class="paragraph_style_14">if (ret != SSL_SUCCESS) {<br/></p>
<p class="paragraph_style_14">err = CyaSSL_get_error(ssl, ret);<br/></p>
<p class="paragraph_style_14">printf(“error = %d, %s\n”, err, CyaSSL_ERR_error_string(err, buffer));<br/>}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_get_error<br/></p>
<p class="paragraph_style_10">CyaSSL_accept<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_13.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_12">CyaSSL_connect_cert<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int CyaSSL_connect_cert(CYASSL* ssl);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">This function is called on the client side and initiates an SSL/TLS handshake with a server only long enough to get the peer’s certificate chain.  When this function is called, the underlying communication channel has already been set up.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">CyaSSL_connect_cert() works with both blocking and non-blocking I/O.  When the underlying I/O is non-blocking, CyaSSL_connect_cert() will return when the underlying I/O could not satisfy the needs of of CyaSSL_connect_cert() to continue the handshake.  In this case, a call to CyaSSL_get_error() will yield either <span class="style_3">SSL_ERROR_WANT_READ</span> or <span class="style_3">SSL_ERROR_WANT_WRITE</span>.  The calling process must then repeat the call to CyaSSL_connect_cert() when the underlying I/O is ready and CyaSSL will pick up where it left off. When using a non-blocking socket, nothing needs to be done, but select() can be used to check for the required condition.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">If the underlying I/O is blocking, CyaSSL_connect_cert() will only return once the peer’s certificate chain has been received.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10">If successful the call will return <span class="style_3">SSL_SUCCESS</span>.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">SSL_FAILURE</span> will be returned if the SSL session parameter is NULL.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">SSL_FATAL_ERROR</span> will be returned if an error occurred.  To get a more detailed error code, call CyaSSL_get_error().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - a pointer to a CYASSL structure, created using CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">int ret = 0;<br/></p>
<p class="paragraph_style_14">int err = 0;<br/></p>
<p class="paragraph_style_14">CYASSL* ssl;<br/></p>
<p class="paragraph_style_14">char buffer[80];<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = CyaSSL_connect_cert(ssl);<br/></p>
<p class="paragraph_style_14">if (ret != SSL_SUCCESS) {<br/></p>
<p class="paragraph_style_14">err = CyaSSL_get_error(ssl, ret);<br/></p>
<p class="paragraph_style_14">printf(“error = %d, %s\n”, err, CyaSSL_ERR_error_string(err, buffer));<br/>}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_get_error<br/></p>
<p class="paragraph_style_10">CyaSSL_connect<br/></p>
<p class="paragraph_style_10">CyaSSL_accept<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_14.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_11"><br/></p>
<p class="paragraph_style_12">CyaSSL_get_fd<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int CyaSSL_get_fd(const CYASSL* ssl);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">This function returns the file descriptor (<span class="style_3">fd</span>) used as the input/output facility for the SSL connection.  Typically this will be a socket file descriptor.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10">If successful the call will return the SSL session file descriptor.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - pointer to the SSL session, created with CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">int sockfd;<br/></p>
<p class="paragraph_style_14">CYASSL* ssl = 0;<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14">sockfd = CyaSSL_get_fd(ssl);<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_set_fd<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_15.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_12">CyaSSL_get_session<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">CYASSL_SESSION* CyaSSL_get_session(CYASSL* ssl);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">This function returns a pointer to the current session (CYASSL_SESSION) used in ssl.  The CYASSL_SESSION pointed to contains all the necessary information required to perform a session resumption and reestablish the connection without a new handshake.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">For session resumption, before calling CyaSSL_shutdown() with your session object, an application should save the session ID from the object with a call to CyaSSL_get_session(), which returns a pointer to the session.  Later, the application should create a new CYASSL object and assign the saved session with CyaSSL_set_session().  At this point, the application may call CyaSSL_connect() and CyaSSL will try to resume the session.  The CyaSSL server code allows session resumption by default.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10">If successful the call will return a pointer to the the current SSL session object.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">NULL</span> will be returned if <span class="style_3">ssl</span> is NULL, the SSL session cache is disabled, CyaSSL doesn’t have the Session ID available, or mutex functions fail.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - pointer to the SSL session, created with CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">CYASSL* ssl = 0;<br/></p>
<p class="paragraph_style_14">CYASSL_SESSION* session = 0;<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14">session = CyaSSL_get_session(ssl);<br/></p>
<p class="paragraph_style_14">if (session == NULL) {<br/></p>
<p class="paragraph_style_14">// failed to get session pointer<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_set_session<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_16.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_12">CyaSSL_get_using_nonblock<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int CyaSSL_get_using_nonblock(CYASSL* ssl);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">This function allows the application to determine if CyaSSL is using non-blocking I/O.  If CyaSSL is using non-blocking I/O, this function will return 1, otherwise 0.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">After an application creates a CYASSL object, if it will be used with a non-blocking socket, call CyaSSL_set_using_nonblock() on it. This lets the CYASSL object know that receiving EWOULDBLOCK means that the recvfrom call would block rather than that it timed out.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span> - underlying I/O is blocking.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">1</span> - underlying I/O is non-blocking<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - pointer to the SSL session, created with CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">int ret = 0;<br/></p>
<p class="paragraph_style_14">CYASSL* ssl = 0;<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14">ret = CyaSSL_get_using_nonblock(ssl);<br/></p>
<p class="paragraph_style_14">if (ret == 1) {<br/></p>
<p class="paragraph_style_14">// underlying I/O is non-blocking<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_set_session<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_17.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_11"><br/></p>
<p class="paragraph_style_12">CyaSSL_flush_sessions<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">void CyaSSL_flush_sessions(CYASSL_CTX *ctx, long tm);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">This function flushes session from the session cache which have expired.  The time, tm, is used for the time comparison.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">Note that CyaSSL currently uses a static table for sessions, so no flushing is needed.  As such, this function is currently just a stub.  This function provides OpenSSL compatibility (SSL_flush_sessions) when CyaSSL is compiled with the OpenSSL compatibility layer.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10">This function does not have a return value.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ctx</span> - a pointer to a CYASSL_CTX structure, created using CyaSSL_CTX_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">tm</span> - time used in session expiration comparison.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">CYASSL_CTX* ssl;<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">CyaSSL_flush_sessions(ctx, time(0));<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_get_session<br/></p>
<p class="paragraph_style_10">CyaSSL_set_session<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_18.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_12">CyaSSL_negotiate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int CyaSSL_negotiate(CYASSL* ssl);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">Performs the actual connect or accept based on the side of the SSL method.  If called from the client side then an CyaSSL_connect() is done while a CyaSSL_accept() is performed if called from the server side.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10"><span class="style_3">SSL_SUCCESS</span> will be returned if successful. (Note, older versions will return 0.)<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">SSL_FATAL_ERROR</span> will be returned if the underlying call resulted in an error. Use CyaSSL_get_error() to get a specific error code.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - pointer to the SSL session, created with CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_15">int ret = SSL_FATAL_ERROR;<br/></p>
<p class="paragraph_style_15">CYASSL* ssl = 0;<br/></p>
<p class="paragraph_style_15">...<br/></p>
<p class="paragraph_style_15">ret = CyaSSL_negotiate(ssl);<br/></p>
<p class="paragraph_style_15">if (ret == SSL_FATAL_ERROR) {<br/></p>
<p class="paragraph_style_15">// SSL establishment failed<br/></p>
<p class="paragraph_style_15">int error_code = CyaSSL_get_error(ssl);<br/></p>
<p class="paragraph_style_15">...<br/></p>
<p class="paragraph_style_15">}<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">SSL_connect<br/></p>
<p class="paragraph_style_10">SSL_accept<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_19.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_12">CyaSSL_peek<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int CyaSSL_peek(CYASSL* ssl, void* data, int sz);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">This function copies <span class="style_3">sz</span> bytes from the SSL session (<span class="style_3">ssl</span>) internal read buffer into the buffer <span class="style_3">data</span>.  This function is identical to CyaSSL_read() except that the data in the internal SSL session receive buffer is not removed or modified.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">If necessary, like CyaSSL_read(), CyaSSL_peek() will negotiate an SSL/TLS session if the handshake has not already been performed yet by CyaSSL_connect() or CyaSSL_accept().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">The SSL/TLS protocol uses SSL records which have a maximum size of 16kB (the max record size can be controlled by the MAX_RECORD_SIZE define in &lt;cyassl_root&gt;/cyassl/internal.h).  As such, CyaSSL needs to read an entire SSL record internally before it is able to process and decrypt the record.  Because of this, a call to CyaSSL_peek() will only be able to return the maximum buffer size which has been decrypted at the time of calling.  There may be additional not-yet-decrypted data waiting in the internal CyaSSL receive buffer which will be retrieved and decrypted with the next call to CyaSSL_peek() / CyaSSL_read().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">If <span class="style_3">sz</span> is larger than the number of bytes in the internal read buffer, SSL_peek() will return the bytes available in the internal read buffer.  If no bytes are buffered in the internal read buffer yet, a call to CyaSSL_peek() will trigger processing of the next record.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">&gt; 0</span> - the number of bytes read upon success.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span> - will be returned upon failure.  This may be caused by a either a clean (close notify alert) shutdown or just that the peer closed the connection.  Call CyaSSL_get_error() for the specific error code.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">SSL_FATAL_ERROR</span> - will be returned upon failure when either an error occurred or, when using non-blocking sockets, the SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE error was received and and the application needs to call CyaSSL_peek() again.  Use CyaSSL_get_error() to get a specific error code.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - pointer to the SSL session, created with CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">data</span> - buffer where CyaSSL_peek() will place data read.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">sz</span> - number of bytes to read into data.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">CYASSL* ssl = 0;<br/></p>
<p class="paragraph_style_14">char reply[1024];<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">input = CyaSSL_peek(ssl, reply, sizeof(reply));<br/></p>
<p class="paragraph_style_14">if (input &gt; 0) {<br/></p>
<p class="paragraph_style_14">// “input” number of bytes returned into buffer “reply”<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_read<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_20.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_12">CyaSSL_pending<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int CyaSSL_pending(CYASSL* ssl);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">This function returns the number of bytes which are buffered and available in the SSL object to be read by CyaSSL_read().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">This function returns the number of bytes pending.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - pointer to the SSL session, created with CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">int pending = 0;<br/></p>
<p class="paragraph_style_14">CYASSL* ssl = 0;<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">pending = CyaSSL_pending(ssl);<br/></p>
<p class="paragraph_style_14">printf(“There are %d bytes buffered and available for reading”, pending);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_recv<br/></p>
<p class="paragraph_style_10">CyaSSL_read<br/></p>
<p class="paragraph_style_10">CyaSSL_peek<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_21.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_12">CyaSSL_read<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int CyaSSL_read(CYASSL* ssl, void* data, int sz);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">This function reads <span class="style_3">sz</span> bytes from the SSL session (<span class="style_3">ssl</span>) internal read buffer into the buffer <span class="style_3">data</span>.  The bytes read are removed from the internal receive buffer.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">If necessary CyaSSL_read() will negotiate an SSL/TLS session if the handshake has not already been performed yet by CyaSSL_connect() or CyaSSL_accept().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">The SSL/TLS protocol uses SSL records which have a maximum size of 16kB (the max record size can be controlled by the MAX_RECORD_SIZE define in &lt;cyassl_root&gt;/cyassl/internal.h).  As such, CyaSSL needs to read an entire SSL record internally before it is able to process and decrypt the record.  Because of this, a call to CyaSSL_read() will only be able to return the maximum buffer size which has been decrypted at the time of calling.  There may be additional not-yet-decrypted data waiting in the internal CyaSSL receive buffer which will be retrieved and decrypted with the next call to CyaSSL_read().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">If <span class="style_3">sz</span> is larger than the number of bytes in the internal read buffer, SSL_read() will return the bytes available in the internal read buffer.  If no bytes are buffered in the internal read buffer yet, a call to CyaSSL_read() will trigger processing of the next record.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">&gt; 0</span> - the number of bytes read upon success.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span> - will be returned upon failure.  This may be caused by a either a clean (close notify alert) shutdown or just that the peer closed the connection.  Call CyaSSL_get_error() for the specific error code.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">SSL_FATAL_ERROR</span> - will be returned upon failure when either an error occurred or, when using non-blocking sockets, the SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE error was received and and the application needs to call CyaSSL_read() again.  Use CyaSSL_get_error() to get a specific error code.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - pointer to the SSL session, created with CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">data</span> - buffer where CyaSSL_read() will place data read.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">sz</span> - number of bytes to read into <span class="style_3">data</span>.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">CYASSL* ssl = 0;<br/></p>
<p class="paragraph_style_14">char reply[1024];<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">input = CyaSSL_read(ssl, reply, sizeof(reply));<br/></p>
<p class="paragraph_style_14">if (input &gt; 0) {<br/></p>
<p class="paragraph_style_14">// “input” number of bytes returned into buffer “reply”<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">See CyaSSL examples (client, server, echoclient, echoserver) for more complete examples of CyaSSL_read().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_recv<br/></p>
<p class="paragraph_style_10">CyaSSL_write<br/></p>
<p class="paragraph_style_10">CyaSSL_peek<br/></p>
<p class="paragraph_style_10">CyaSSL_pending<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_22.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_12">CyaSSL_recv<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int CyaSSL_recv(CYASSL* ssl, void* data, int sz, int flags);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">This function reads <span class="style_3">sz</span> bytes from the SSL session (<span class="style_3">ssl</span>) internal read buffer into the buffer <span class="style_3">data</span> using the specified <span class="style_3">flags</span> for the underlying recv operation.  The bytes read are removed from the internal receive buffer.  This function is identical to CyaSSL_read() except that it allows the application to set the recv flags for the underlying read operation.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">If necessary CyaSSL_recv() will negotiate an SSL/TLS session if the handshake has not already been performed yet by CyaSSL_connect() or CyaSSL_accept().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">The SSL/TLS protocol uses SSL records which have a maximum size of 16kB (the max record size can be controlled by the MAX_RECORD_SIZE define in &lt;cyassl_root&gt;/cyassl/internal.h).  As such, CyaSSL needs to read an entire SSL record internally before it is able to process and decrypt the record.  Because of this, a call to CyaSSL_recv() will only be able to return the maximum buffer size which has been decrypted at the time of calling.  There may be additional not-yet-decrypted data waiting in the internal CyaSSL receive buffer which will be retrieved and decrypted with the next call to CyaSSL_recv().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">If <span class="style_3">sz</span> is larger than the number of bytes in the internal read buffer, SSL_recv() will return the bytes available in the internal read buffer.  If no bytes are buffered in the internal read buffer yet, a call to CyaSSL_recv() will trigger processing of the next record.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">&gt; 0</span> - the number of bytes read upon success.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span> - will be returned upon failure.  This may be caused by a either a clean (close notify alert) shutdown or just that the peer closed the connection.  Call CyaSSL_get_error() for the specific error code.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">SSL_FATAL_ERROR</span> - will be returned upon failure when either an error occurred or, when using non-blocking sockets, the SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE error was received and and the application needs to call CyaSSL_recv() again.  Use CyaSSL_get_error() to get a specific error code.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - pointer to the SSL session, created with CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">data</span> - buffer where CyaSSL_recv() will place data read.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">sz</span> - number of bytes to read into <span class="style_3">data</span>.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">flags</span> - the recv flags to use for the underlying recv operation.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">CYASSL* ssl = 0;<br/></p>
<p class="paragraph_style_14">char reply[1024];<br/></p>
<p class="paragraph_style_14">int flags = ... ;<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">input = CyaSSL_recv(ssl, reply, sizeof(reply), flags);<br/></p>
<p class="paragraph_style_14">if (input &gt; 0) {<br/></p>
<p class="paragraph_style_14">// “input” number of bytes returned into buffer “reply”<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_read<br/></p>
<p class="paragraph_style_10">CyaSSL_write<br/></p>
<p class="paragraph_style_10">CyaSSL_peek<br/></p>
<p class="paragraph_style_10">CyaSSL_pending<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_23.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">CyaSSL_send<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int CyaSSL_send(CYASSL* ssl, const void* data, int sz, int flags);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">This function writes <span class="style_3">sz</span> bytes from the buffer, <span class="style_3">data</span>, to the SSL connection, <span class="style_3">ssl</span>, using the specified <span class="style_3">flags</span> for the underlying write operation.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">If necessary CyaSSL_send() will negotiate an SSL/TLS session if the handshake has not already been performed yet by CyaSSL_connect() or CyaSSL_accept().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">CyaSSL_send() works with both blocking and non-blocking I/O.  When the underlying I/O is non-blocking, CyaSSL_send() will return when the underlying I/O could not satisfy the needs of of CyaSSL_send to continue.  In this case, a call to CyaSSL_get_error() will yield either <span class="style_3">SSL_ERROR_WANT_READ</span> or <span class="style_3">SSL_ERROR_WANT_WRITE</span>.  The calling process must then repeat the call to CyaSSL_send() when the underlying I/O is ready.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">If the underlying I/O is blocking, CyaSSL_send() will only return once the buffer data of size sz has been completely written or an error occurred.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">&gt; 0</span> - the number of bytes written upon success.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span> - will be returned upon failure.  Call CyaSSL_get_error() for the specific error code.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">SSL_FATAL_ERROR</span> - will be returned upon failure when either an error occurred or, when using non-blocking sockets, the SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE error was received and and the application needs to call CyaSSL_send() again.  Use CyaSSL_get_error() to get a specific error code.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - pointer to the SSL session, created with CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">data</span> - data buffer to send to peer.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">sz</span> - size, in bytes, of <span class="style_3">data</span> to be sent to peer.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">flags</span> - the send flags to use for the underlying send operation.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">CYASSL* ssl = 0;<br/></p>
<p class="paragraph_style_14">char msg[64] = “hello cyassl!”;<br/></p>
<p class="paragraph_style_14">int msgSz = (int)strlen(msg);<br/></p>
<p class="paragraph_style_14">int flags = ... ;<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">input = CyaSSL_send(ssl, msg, msgSz, flags);<br/></p>
<p class="paragraph_style_14">if (input != msgSz) {<br/></p>
<p class="paragraph_style_14">// CyaSSL_send() failed<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_write<br/></p>
<p class="paragraph_style_10">CyaSSL_read<br/></p>
<p class="paragraph_style_10">CyaSSL_recv<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_24.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_12">CyaSSL_write<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int CyaSSL_write(CYASSL* ssl, const void* data, int sz);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">This function writes <span class="style_3">sz</span> bytes from the buffer, <span class="style_3">data</span>, to the SSL connection, <span class="style_3">ssl</span>.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">If necessary, CyaSSL_write() will negotiate an SSL/TLS session if the handshake has not already been performed yet by CyaSSL_connect() or CyaSSL_accept().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">CyaSSL_write() works with both blocking and non-blocking I/O.  When the underlying I/O is non-blocking, CyaSSL_write() will return when the underlying I/O could not satisfy the needs of of CyaSSL_write() to continue.  In this case, a call to CyaSSL_get_error() will yield either <span class="style_3">SSL_ERROR_WANT_READ</span> or <span class="style_3">SSL_ERROR_WANT_WRITE</span>.  The calling process must then repeat the call to CyaSSL_write() when the underlying I/O is ready.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">If the underlying I/O is blocking, CyaSSL_write() will only return once the buffer <span class="style_3">data</span> of size <span class="style_3">sz</span> has been completely written or an error occurred.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">&gt; 0</span> - the number of bytes written upon success.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span> - will be returned upon failure.  Call CyaSSL_get_error() for the specific error code.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">SSL_FATAL_ERROR</span> - will be returned upon failure when either an error occurred or, when using non-blocking sockets, the SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE error was received and and the application needs to call CyaSSL_write() again.  Use CyaSSL_get_error() to get a specific error code.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - pointer to the SSL session, created with CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">data</span> - data buffer which will be sent to peer.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">sz</span> - size, in bytes, of data to send to the peer (<span class="style_3">data</span>).<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">CYASSL* ssl = 0;<br/></p>
<p class="paragraph_style_14">char msg[64] = “hello cyassl!”;<br/></p>
<p class="paragraph_style_14">int msgSz = (int)strlen(msg);<br/></p>
<p class="paragraph_style_14">int flags;<br/></p>
<p class="paragraph_style_14">int ret;<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = CyaSSL_write(ssl, msg, msgSz);<br/></p>
<p class="paragraph_style_14">if (ret &lt;= 0) {<br/></p>
<p class="paragraph_style_14">// CyaSSL_write() failed, call CyaSSL_get_error()<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">See CyaSSL examples (client, server, echoclient, echoserver) for more more detailed examples of CyaSSL_write().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_send<br/></p>
<p class="paragraph_style_10">CyaSSL_read<br/></p>
<p class="paragraph_style_10">CyaSSL_recv<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_25.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_12">CyaSSL_writev<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;cyassl/ssl.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int CyaSSL_writev(CYASSL* ssl, const struct iovec* iov, int iovcnt);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_10">Simulates writev semantics but doesn’t actually do block at a time because of SSL_write() behavior and because front adds may be small.  Makes porting into software that uses writev easier.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">&gt; 0</span> - the number of bytes written upon success.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span> - will be returned upon failure.  Call CyaSSL_get_error() for the specific error code.<br/></p>
<p class="paragraph_style_16"><br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_ERROR</span> will be returned if a memory error was encountered.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">SSL_FATAL_ERROR</span> - will be returned upon failure when either an error occurred or, when using non-blocking sockets, the SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE error was received and and the application needs to call CyaSSL_write() again.  Use CyaSSL_get_error() to get a specific error code.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">ssl</span> - pointer to the SSL session, created with CyaSSL_new().<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">iov</span> - array of I/O vectors to write<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">iovcnt</span> - number of vectors in <span class="style_3">iov</span> array.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">CYASSL* ssl = 0;<br/></p>
<p class="paragraph_style_14">char *bufA = “hello\n”;<br/></p>
<p class="paragraph_style_14">char *bufB = “hello world\n”;<br/></p>
<p class="paragraph_style_14">int iovcnt;<br/></p>
<p class="paragraph_style_14">struct iovec iov[2];<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">iov[0].iov_base = buffA;<br/></p>
<p class="paragraph_style_14">iov[0].iov_len = strlen(buffA);<br/></p>
<p class="paragraph_style_14">iov[1].iov_base = buffB;<br/></p>
<p class="paragraph_style_14">iov[1].iov_len = strlen(buffB);<br/></p>
<p class="paragraph_style_14">iovcnt = 2;<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = CyaSSL_writev(ssl, iov, iovcnt);<br/></p>
<p class="paragraph_style_14">// wrote “ret” bytes, or error if &lt;= 0.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_10">CyaSSL_write<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_26.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
</div>
<div style="clear: both; height: 0px; line-height: 0px; " class="tinyText"> </div>
</div>
</div>
<div style="height: 16px; width: 20px;  height: 16px; left: 706px; position: absolute; top: 51px; width: 20px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 20px; ">
<img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/shapeimage_27.png" alt="" style="height: 16px; left: 0px; position: absolute; top: 0px; width: 20px; "/>
</div>
</div>
<div style="height: 19px; width: 19px;  height: 19px; left: 707px; position: absolute; top: 25px; width: 19px; z-index: 1; " class="tinyText style_SkipStroke_2">
<img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/United%20Kingdom(Great%20Britain).png" alt="" style="border: none; height: 19px; width: 19px; "/>
</div>
<div id="id17" style="height: 23px; left: 328px; position: absolute; top: 48px; width: 258px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_258_23" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_17">Questions? +1 (425) 245-8247</p>
</div>
</div>
</div>
<div style="height: 19px; width: 19px;  height: 19px; left: 685px; position: absolute; top: 25px; width: 19px; z-index: 1; " class="tinyText style_SkipStroke_2">
<a href="http://www.wolfssl.jp/" title="http://www.wolfssl.jp"><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/japan.png" alt="" style="border: none; height: 19px; width: 19px; "/></a>
</div>
<div id="id18" style="height: 28px; left: 593px; position: absolute; top: 44px; width: 119px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_119_28" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_18"><a class="class14" title="https://www.wolfssl.com/forums" href="https://www.wolfssl.com/forums">Support <span class="style_4">Forums</span></a></p>
</div>
</div>
</div>
<div style="height: 121px; width: 155px;  height: 121px; left: 32px; position: absolute; top: 5px; width: 155px; z-index: 1; " class="tinyText style_SkipStroke_2">
<a href="Home.html" title="Home.html"><img src="Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io_files/wolfssl_logo.png" alt="" style="border: none; height: 121px; width: 156px; "/></a>
</div>
<div style="height: 11159px; line-height: 11159px; " class="spacer"> </div>
</div>
<div style="height: 100px; margin-left: 0px; position: relative; width: 770px; z-index: 15; " id="footer_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
<div id="id19" style="height: 27px; left: 634px; position: absolute; top: 27px; width: 102px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_102_27" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_4"><a class="class15" title="Docs-wolfssl-manual-17-9-wolfssl-api-dtls.html" href="Docs-wolfssl-manual-17-9-wolfssl-api-dtls.html">Next Chapter</a></p>
</div>
</div>
</div>
<div id="id20" style="height: 25px; left: 35px; position: absolute; top: 27px; width: 125px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_125_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_19"><a class="class16" title="Docs-wolfssl-manual-17-7-wolfssl-api-informational.html" href="Docs-wolfssl-manual-17-7-wolfssl-api-informational.html">Previous Chapter</a></p>
</div>
</div>
</div>
<div id="id21" style="height: 25px; left: 323px; position: absolute; top: 27px; width: 125px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_125_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_7"><a class="class17" title="Docs-wolfssl-manual-toc.html" href="Docs-wolfssl-manual-toc.html">Table of Contents</a></p>
</div>
</div>
</div>
<div id="id22" style="height: 29px; left: 35px; position: absolute; top: 65px; width: 701px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_701_29" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_20">Copyright 2017 wolfSSL Inc.  All rights reserved.</p>
</div>
</div>
</div>
</div>
</div>
</div>
 </body>

<!-- Mirrored from www.wolfssl.com/wolfSSL/Docs-wolfssl-manual-17-8-wolfssl-api-connection-session-io.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Jan 2017 13:35:27 GMT -->
</html>
